Access Counter ( 9 April 95 )

--------------------------------------------------------------------
About Access Counter

I brought up the CERN WWW server on my home network and wrote a Tcl script to keep track of page hits as a way to learn how to write CGI scripts. When I decided to release the script I found that halcyon did not support Tcl but they do support PERL. I re-wrote the script in PERL and placed it in the /archive/local/htbin directory on halcyon.

The only browsers I had checked the script with were netscape and mosaic but I soon learned that there were a few browsers that had trouble with number.pl.

To investigate this problem I installed OS/2 WARP on one of my systems and experimented with WebExplorer. I found that the number showed up as a broken icon. The problem turned out to be the way WebExplorer handled output type
Content-type: type/xbm\n.

To fix the problem I changed the script to number.xbm and modified it to output
Content-type: image/x-xbitmap\n.
The script now works with netscape, mosaic and WebExplorer.

I have reports that AirMosic from Internet In A Box has trouble with number.xbm but I have not spent any time investigating the problem.

The way the script works is to construct a dynamic bitmap image from a number supplied by any file specified in the tagging. Then the file is updated by adding one to the number.

There is only one number.xbm script in /archive/local/htbin and there is the possibility of a number of users accessing the same counter file at the same time. The script prevents problems from occurring due to multiple user access.

Server Setup Requirements

The CERN server setup script on halcyon is called httpd.conf and is used by the server to setup directories. On halcyon the server settings are as follows:
           #
           #       User-supported directories under ~/public_html
           #
           UserDir /archive/pub/local/

           #
           #       Scripts; URLs starting with /cgi-bin/ will be understood as
           #       script calls in the directory /your/script/directory
           #
           Exec /htbin/* /archive/pub/local/htbin/*
           
The number.xbm script depends on the server UsrDir to be set to /archive/local and the Exec to be set to /htbin/* /archive/pub/local/htbin/* . (On halcyon /archive/local and /archive/pub/local are equivalent.) If your server uses different names, the script must be modified to reflect your server assigned names. Change all references to /archive/local to reflect your servers UserDir.

The first line of the PERL script points to the PERL program. This file may reside in another directory on some systems so this line may need to be modified.

Your WWW server must have an htbin that you have write access to. If you do not have write access to this area, your systems administrator will have to add the script for you.

CAUTION: I have assumed that your site is set up in a way that prevents users from trashing files in their http directory. At halcyon number files are located under each users part of the http directory and ifile access of the number file must be set to 777. Hopefully users do not give full access to other files in their directory and do not use file names that are not counter files.
My understanding is that the NCSA server handles CGI scripts differently but I have not looked into it.

Installation

The following instructions should be all the information necessary to add number.xbm to your system.

  1. Locate the htbin directory on your system.
  2. Down load the number.xbmx file.
  3. Rename the file to number.xbm
      rn number.xbmx number.xbm
  4. place the file in the CGI directory
      mv number.xbm /archive/local/htbin
  5. Set the mode bits to public read execute
      chmod 755 /archive/local/htbin
  6. Create a number.val file with six lines containing a 0 on each line.
      I put the number.val file with my home page and gave it public read/write access ( chmod 777 number.val). For me the file lives in
      /archive/local/gened/number.val
  7. Add a reference to your home page that looks something like
    ..IMG SRC="http://www../htbin/number.xbm/your_dir/number.val"..
      The tagging on my home page reads
      ..IMG ALIGN=bottom SRC="/htbin/number.xbm/gened/number.val"..
  8. Run your browser and check the counter. It should increment by one every time you reload the page.

Other Versions

There are two other versions of this program available in the public ftp archive on halcyon under the gened directory. A tcl version called number.tcl and the original PERL version called number.pl



Gene's Home Page

Halcyon's Home Page

Comments, feedback, potential additions to this area, please write:

gened@halcyon.com